import request from '@/utils/request'

// 获取一级图册
export function getRootAtlas() {
  return request({
    method: 'GET',
    url: `/app/v1/atlas/getRootAtlas`
  })
}

// /atlas/getListByAtlasId/{atlasId}
// 根据末级id获取图片列表
export function getListByAtlasId(atlasId) {
  return request({
    method: 'GET',
    url: `/app/v1/atlas/getListByAtlasId/${atlasId}`
  })
}
// /atlas/getTreeById/{atlasId}
// 根据一级图册id获取树形
export function getTreeById(atlasId) {
  return request({
    method: 'GET',
    url: `/app/v1/atlas/getTreeById/${atlasId}`
  })
}

// 图册预览记录保存
export function saveAtlasBrowsingHistory({ atlasId, atlasName }) {
  return request({
    method: 'POST',
    url: `/app/v1/browsingHistoryAtlas`,
    data: { atlasId, atlasName, clientCode: 'SAD-APP' }
  })
}

// 根据id获取图册
export async function getAtlasState(id) {
  const res = await request({
    method: 'GET',
    url: `/app/v1/atlas/${id}`
  })
  return !!(res && res.data && res.data.state)
}
